package com.woniu.liuzhougov.systemSettings.controller;

import com.woniu.liuzhougov.systemSettings.dto.LogDto;
import com.woniu.liuzhougov.systemSettings.pojo.Log;
import com.woniu.liuzhougov.systemSettings.service.LogService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @Description: 日志管理
 * @Author: yuetang
 * @Date: 2019-04-23 16:08
 */
@Controller
public class LogController {

    @Resource
    private LogService logService;

    @RequiresPermissions("log_selAll")
    @RequestMapping("/log/selAll")
    @ResponseBody
    public Map selAll(){
        List<LogDto> list = logService.selAll();
        Map<String,Object> map = new HashMap<>();
        map.put("count",list.size());
        map.put("data",list);
        map.put("code",0);
        map.put("msg","");
        return map;
    }

    //模糊查询
    @RequestMapping("/log/selLike")
    @ResponseBody
    public Map selLike(LogDto logDto) {
        System.out.println(logDto.getItemName());
        System.out.println(logDto.getUserName());
        List<LogDto> list = logService.sellLike(logDto);
        Map<String,Object> map = new HashMap<>();
        map.put("count",list.size());
        map.put("data",list);
        map.put("code",0);
        map.put("msg","");
        return map;
    }
    //添加类型
    @RequestMapping("/log/insert")
    @ResponseBody
    public String insert(Log log){
        return  logService.insert(log);
    }

}
